;; import files/words.scm data-structures/trie.scm lists/standard.scm puzzles/anagrams.scm

;; Puzzles taken off some countdown website

(define countdown-puzzles
  '("tifferoid" ;; fortified
    "partydive" ;; depravity
    "iantingle" ;; entailing
    "rhinetide" ;; inherited
    "gluedivan" ;; devaluing
    "nickinegs" ;; sickening
    "noniguilt" ;; outlining
    "hapicarol" ;; parochial
    "mannigout" ;; amounting
    "panchoree" ;; chaperone
    "nyccegirl" ;; recycling
    "quitesexi" ;; exquisite
    "doggirunn" ;; grounding
    ))

(define t (make-trie))

(define num-words 0)

(for-each (lambda (word)
	    (set! num-words (+ 1 num-words))
	    (set! t (extend-trie t word)))
	  (with-input-from-file "data/9letterwords.txt" words))

(print `(added ,num-words words to the dictionary))

(for-each (lambda (conundrum)
	    (let ((answers (anagrams t (string->list conundrum) '())))
	      (if (null? answers)
		  (print `(could not solve ,conundrum))
		  (print `(,conundrum -> ,(list->string (car answers)))))))
	  countdown-puzzles)
